<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
	<title>欢迎使用-心情指数后台管理系统</title>
	<%@ include file="layouts/top.jsp"%>
	<script type="text/javascript">
		$(function() {  
			if (parent.window != window) {//含有父窗体
				parent.window.location.href = getHttpRequestPath("/");
			}
			$("#submitButton").click(submit);
			$("#userId").focus();
			changeVerifyImgSrc();
			$("#verifyCodeTr").hide();
		});
		
		function changeVerifyImgSrc() {
			var verifyImg = document.getElementById("VerImg");
			var path = "<c:url value='/verifyCode?s=' />" + Math.floor(Math.random() * 100000000);
			verifyImg.src = path;
		}
		
		function submit() {
			if ($("#userId").val().trim() == "") {
				alert("请输入用户名");
				$("#userId").focus();
				return;
			}
			if ($("#password").val() == "") {
				alert("请输入密码");
				$("#password").focus();
				return;
			}
			if ($("#validcode_textbox").val().trim() == "") {
				//alert("请输入验证码");
				//$("#validcode_textbox").focus();
				//return;
				$.ajax({
					url:getHttpRequestPath("getValidCode"),
					data:{},
					success:function(typesString) {
						$("#validcode_textbox").val(typesString);
					},
					async:false
				});
			}
			$("#loginForm").submit();
		}
	</script>
</head>

<body style="padding:100px;" onkeydown="keyCode(event)">
	<table height="100%" align="center" valign="middle">
		<tr>
        	<td align="center">
				<p style="font-size:200%; font-weight:bold;">心情指数后台管理系统</p>
			</td>
        </tr>
		<tr>
			<td>
				${tip}
				<form id="loginForm" action="index" method="post" class="form-horizontal">
					<table>
						<tr>
							<td>用户名:</td>
							<td>
								<input type='text' id='userId' name='userId' class="input-medium required"/>
							</td>
						</tr>
						<tr>
							<td>密码:</td>
							<td>
								<input type="password" id="password" name="password" class="input-medium required"/>
							</td>
						</tr>
						<tr id="verifyCodeTr">
							<td>验证码</td>
							<td>
								<input type="text" id="validcode_textbox" name="verifyCode" style="width: 60px;" class="input-medium required"/>
								<img id="VerImg" style="cursor: hand" alt="点击刷新验证码" onclick="changeVerifyImgSrc()" />
							</td>
						</tr>
						<tr>
							<td colspan='2' align="center">
								<button type="button" id="submitButton">登录</button>
								&nbsp;&nbsp;&nbsp;
								<input value="重置" type="reset" class="button" data-dismiss="alert"/>
							</td>
						</tr>
					</table>
				</form>
			</td>
		</tr>
	</table>
</body>
</html>
